void sort(int a[], int n) {
  int i, j, k, t;
  for (i = 0; i < n - 1; i++) {
    for (k = i, j = i + 1; j < n; j++)
      if (a[j] < a[k])
        k = j;
    if (k != i)
      t = a[i], a[i] = a[k], a[k] = t;
  }
}

void print(int a[], int n) {
  int i;
  for (i = 0; i < n; i++)
    printf("%d ", a[i]);
  printf("\n");
}

int main() {
  int a[] =  {
    5, 1, 4, 2, 3
  };
  int n = sizeof(a) / sizeof(a[0]);
  print(a, n);
  sort(a, n);
  print(a, n);
}
